#!/bin/sh

# srcdir is the directory where this script resides
srcdir="$(cd `dirname "$0"` && pwd)"
progname="`basename "$0"`"
. ${srcdir}/env.sh

cd $resultdir

$awk '
	/<b>Monatsmiete:<\/b>/ || /<b>Betriebskosten:<\/b>/ {
		parsing=1
	}
	
	parsing && length($0) {
		print
		parsing=0
	}
' | $sed -E -e 's/^.*<\/b> //g' -e 's/<.*//g' -e 's/,.*//g' -e 's/^0+/0/g' -e 's/([0-9]+).*$/\1/g' -e 's/^[^0-9]+/0/g' | 9 sed -e 's/[^0-9]//g' |
$awk '
	NR%2 == 0 {
		tmp = $1
	}
	NR%2 == 1 {
		tmp += $1
		print tmp
		tmp = 0
	}
'
